package com.hsylient.resource;

import com.hsylient.resource.config.ConfigFromAnnotation;
import com.hsylient.resource.config.ConfigFromBindingEntity;
import com.hsylient.resource.entity.Student;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import java.util.Arrays;

// @SpringBootApplication默认扫描当前类所在的包和当前类的子包，或者显示的配置
@SpringBootApplication
@EnableConfigurationProperties(ConfigFromBindingEntity.class)
public class ResourceApplication {

    public static void main(String[] args) {
        var ioc = SpringApplication.run(ResourceApplication.class, args);

        // 获取容器中所有bean的名字
        Arrays.stream(ioc.getBeanDefinitionNames()).toList().forEach(System.out::println);

        ConfigFromBindingEntity entity = ioc.getBean(ConfigFromBindingEntity.class);
        System.out.println(entity);

        ConfigFromAnnotation bean = ioc.getBean(ConfigFromAnnotation.class);
        System.out.println(bean.getDescription());

        Student bean1 = ioc.getBean(Student.class);
        System.out.println(bean1);
    }
}
